#pragma once

#include "MyActiveInterface.h"

namespace CO { namespace MyGroupNamespace { namespace MyPackageNamespace {

class MyActiveHSM :
	public SpiFoundation::RoomFW::ActiveHSM, // QHsm must be first!!!
	public MyActiveInterface
{
public:

	//
	// Constructor/Destructor.
	//
	MyActiveHSM();
	virtual ~MyActiveHSM();

	//
	// ISystemComponent overrides.
	//
	virtual bool initialize(SpiFoundation::Configuration::ConfigKey& configRoot);

	//
	// IActiveObject overrides.
	//
	virtual SpiFoundation::RoomFW::ObjectId getObjectId(void) const;
	virtual const char* getObjectName(void) const;

protected:

	//
	// Handle is overriden to provide a common try/catch block.
	//
	virtual void handle(SpiFoundation::RoomFW::RoomMessageSP message);

	//
	// Hook methods called by DefaultErrorReporting.
	//
	virtual void onError(SpiFoundation::ErrorHandling::IError& e);
	virtual void onException(std::exception& e);
	virtual void onCatchAllException();

	//
	// TODO:  Define an initial state, distinct from normal states.
	//
	static void Initial(MyActiveHSM* me, QEvent const *evt);

	//
	// QHsm defines states as static methods.  They take the this pointer
	// and an event as parameters and return 0 if they handled the event
	// or their parent state if they did not handle the event.  That's how
	// the hierarchy is established, by the state handler return values.
	//
	// Note:  This HSM has three states:  StateA which contains StateB and StateC.
	//
	static QSTATE StateA(MyActiveHSM* me, QEvent const *evt);
	static QSTATE StateB(MyActiveHSM* me, QEvent const *evt);
	static QSTATE StateC(MyActiveHSM* me, QEvent const *evt);

	//
	// The error state demonstrates basic error handling.
	//
	static QSTATE ErrorState(MyActiveHSM* me, QEvent const *evt);

private:

	//
	// TODO:  Add private attributes.
	//
	long myConfigValue_;
};
//
// TODO:  Add a smart pointer typedef for your class.
//
typedef ::boost::shared_ptr<MyActiveHSM> MyActiveHsmSP;

}}} // End namespace
